<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('报废原因列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">


            <form id="role-form">
                <div class="select-list">
                    <ul>

                        <li>
                            partStatus:<input type="text" name="partStatus"/>
                        </li>


                        <li>
                            description：<input type="text" name="description"/>
                        </li>

                        <li>
                            demandFlag：<select name="demandFlag" th:with="type=${@dict.getType('sys_yes_no')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>

                        <li>
                            onhandFlag：<select name="onhandFlag" th:with="type=${@dict.getType('sys_yes_no')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>

                        <li>
                            supplyFlag：<select name="supplyFlag" th:with="type=${@dict.getType('sys_yes_no')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>

                        <li>
                            defaultStatus：<select name="defaultStatus" th:with="type=${@dict.getType('sys_yes_no')}">
                            <option value="">所有</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>




                    </ul>
                </div>
            </form>


        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="InventoryStatuses:InventoryStatus:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="InventoryStatuses:InventoryStatus:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="InventoryStatuses:InventoryStatus:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="InventoryStatuses:InventoryStatus:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>

    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">


    var editFlag = [[${@permission.hasPermi('InventoryStatuses:InventoryStatus:edit')}]];
    var removeFlag = [[${@permission.hasPermi('InventoryStatuses:InventoryStatus:remove')}]];
    var ctx = [[@{/}]];
        var prefix = ctx + "inventoryStatuses";
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/findInventoryStatus/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName:"报废原因",
                columns: [{
                    checkbox: true
                },


                    {
                        field: 'rowkey',
                        title: '主键',
                        sortable: true
                    },
                    {
                        field: 'partStatus',
                        title: 'partStatus',
                        sortable: true
                    },
                    {
                        field: 'description',
                        title: 'description'
                    },
                    {
                        field: 'demandFlag',
                        title: 'demandFlag',
                        sortable: true
                    },
                    {
                        field: 'onhandFlag',
                        title: 'onhandFlag',
                        sortable: true
                    },
                    {
                        field: 'supplyFlag',
                        title: 'supplyFlag'
                    },


                    {
                        visible: editFlag == 'hidden' ? false : true,
                        field: 'defaultStatus',
                        title: 'defaultStatus',
                        formatter: function (value, row, index) {
                            return statusTools(row);
                        }
                    },


                    {
                        field: 'rowversion',
                        title: 'rowversion',
                        sortable: true
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.rowkey + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.rowkey + '\')"><i class="fa fa-remove"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                  ]
            };


            $.table.init(options);
        });
    /* defaultStatus*/
    function statusTools(row) {
        if (row.defaultStatus == 'TRUE') {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="enable(\'' + row.rowkey + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="disable(\'' + row.rowkey + '\')"></i> ';
        }
    }
    /* defaultStatus-否 */
    function enable(rowkey) {
        $.modal.confirm("确认不要检查吗？", function() {
            $.operate.post(prefix + "/edit", { "rowkey": rowkey, "defaultStatus":'FALSE'  });
        })
    }

    /* defaultStatus-是 */
    function disable(rowkey) {
        $.modal.confirm("确认要检查吗？", function() {
            $.operate.post(prefix + "/edit", { "rowkey": rowkey, "defaultStatus": 'TRUE' });
        })
    }



</script>
<style>
    .select-list {
        color: #333333;
        margin: 10px 50px 10px 5px;
    }
</style>

</body>
</html>


